Security News
NIST Misses 2024 Deadline to Clear NVD Backlog
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
currency-symbol-map
Advanced tools
A function to lookup the currency symbol for a given currency code
The currency-symbol-map npm package provides a simple way to get the currency symbol for a given currency code or country. It is useful for applications that need to display currency symbols dynamically based on user input or locale settings.
Get currency symbol by currency code
This feature allows you to get the currency symbol for a given currency code. For example, passing 'USD' will return the dollar symbol '$'.
const currencySymbolMap = require('currency-symbol-map');
const symbol = currencySymbolMap('USD');
console.log(symbol); // Output: $
Get currency symbol by country name
This feature allows you to get the currency symbol for a given country name. For example, passing 'United States' will return the dollar symbol '$'.
const currencySymbolMap = require('currency-symbol-map');
const symbol = currencySymbolMap('United States');
console.log(symbol); // Output: $
Get currency code by currency symbol
This feature allows you to get the currency code for a given currency symbol. For example, passing '€' will return the currency code 'EUR'.
const currencySymbolMap = require('currency-symbol-map');
const code = currencySymbolMap.symbolToCurrency('€');
console.log(code); // Output: EUR
The currency-codes package provides a comprehensive list of currency codes and their associated information, including symbols. It is more detailed and includes additional information such as currency names and numeric codes, but it requires more effort to extract just the symbol.
The currency-formatter package allows for formatting numbers as currency strings, including the appropriate currency symbol. It is more focused on formatting and includes options for locale-specific formatting, making it more versatile for applications that need to display formatted currency values.
The iso-currency package provides ISO 4217 currency codes and their associated information, including symbols. It is similar to currency-codes but focuses specifically on ISO standards, making it a good choice for applications that need to adhere to these standards.
A function to lookup the currency symbol for a given currency code.
npm install currency-symbol-map
// ES5
const getSymbolFromCurrency = require('currency-symbol-map')
// ES6
import getSymbolFromCurrency from 'currency-symbol-map'
getSymbolFromCurrency('GBP') //=> '£'
getSymbolFromCurrency('EUR') //=> '€'
getSymbolFromCurrency('USD') //=> '$'
getSymbolFromCurrency('NOT A VALID CODE') //=> undefined
// ES5
const currencyToSymbolMap = require('currency-symbol-map/map')
// ES6
import currencyToSymbolMap from 'currency-symbol-map/map'
console.log(currencyToSymbolMap)
// =>
{
"USD": "$",
"GBP": "£",
…
}
npm test
'?'
character. It now returns
undefined
so that it is up to you how to handle the failure.Currency symbols originally sourced from xe, but maintained and updated by contributors.
FAQs
A function to lookup the currency symbol for a given currency code
The npm package currency-symbol-map receives a total of 170,878 weekly downloads. As such, currency-symbol-map popularity was classified as popular.
We found that currency-symbol-map demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.